package com.ruoyi.fun.service.impl;

import java.util.List;
import com.ruoyi.common.utils.DateUtils;
import com.ruoyi.common.utils.SecurityUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import com.ruoyi.fun.mapper.EcProductSpecMapper;
import com.ruoyi.fun.domain.EcProductSpec;
import com.ruoyi.fun.service.IEcProductSpecService;

/**
 * 商品规格Service业务层处理
 * 
 * @author ruoyi
 * @date 2025-08-06
 */
@Service
public class EcProductSpecServiceImpl implements IEcProductSpecService 
{
    @Autowired
    private EcProductSpecMapper ecProductSpecMapper;

    /**
     * 查询商品规格
     * 
     * @param specId 商品规格主键
     * @return 商品规格
     */
    @Override
    public EcProductSpec selectEcProductSpecBySpecId(Long specId)
    {
        return ecProductSpecMapper.selectEcProductSpecBySpecId(specId);
    }

    /**
     * 查询商品规格列表
     * 
     * @param ecProductSpec 商品规格
     * @return 商品规格
     */
    @Override
    public List<EcProductSpec> selectEcProductSpecList(EcProductSpec ecProductSpec)
    {
        return ecProductSpecMapper.selectEcProductSpecList(ecProductSpec);
    }

    /**
     * 新增商品规格
     * 
     * @param ecProductSpec 商品规格
     * @return 结果
     */
    @Override
    public int insertEcProductSpec(EcProductSpec ecProductSpec)
    {
        ecProductSpec.setCreateTime(DateUtils.getNowDate());
        ecProductSpec.setOrgId(SecurityUtils.getDeptId());
        return ecProductSpecMapper.insertEcProductSpec(ecProductSpec);
    }

    /**
     * 修改商品规格
     * 
     * @param ecProductSpec 商品规格
     * @return 结果
     */
    @Override
    public int updateEcProductSpec(EcProductSpec ecProductSpec)
    {
        ecProductSpec.setUpdateTime(DateUtils.getNowDate());
        return ecProductSpecMapper.updateEcProductSpec(ecProductSpec);
    }

    /**
     * 批量删除商品规格
     * 
     * @param specIds 需要删除的商品规格主键
     * @return 结果
     */
    @Override
    public int deleteEcProductSpecBySpecIds(Long[] specIds)
    {
        Long orgId = SecurityUtils.getDeptId();
        return ecProductSpecMapper.deleteEcProductSpecBySpecIds(specIds, orgId);
    }

    /**
     * 删除商品规格信息
     * 
     * @param specId 商品规格主键
     * @return 结果
     */
    @Override
    public int deleteEcProductSpecBySpecId(Long specId)
    {
        Long orgId = SecurityUtils.getDeptId();
        return ecProductSpecMapper.deleteEcProductSpecBySpecId(specId, orgId);
    }

    /**
     * 根据specId和组织ID查询ProductSpec
     * 
     * @param specId ProductSpec主键
     * @param orgId 组织ID
     * @return ProductSpec
     */
    @Override
    public EcProductSpec selectEcProductSpecBySpecIdAndOrgId(Long specId, Long orgId)
    {
        return ecProductSpecMapper.selectEcProductSpecBySpecIdAndOrgId(specId, orgId);
    }

    /**
     * 根据组织ID查询ProductSpec列表
     * 
     * @param ecproductspec ProductSpec
     * @param orgId 组织ID
     * @return ProductSpec集合
     */
    @Override
    public List<EcProductSpec> selectEcProductSpecListByOrgId(EcProductSpec ecproductspec, Long orgId)
    {
        return ecProductSpecMapper.selectEcProductSpecListByOrgId(ecproductspec, orgId);
    }
}